import {defineStore} from "pinia";
import {ref} from "vue";
import type {UploadAnimal} from "@/types/upload";
import type {UniFilePickerTempFile} from "@uni-helper/uni-ui-types";

export const useUploadStore = defineStore('upload', () => {
        const uploadData = ref<UploadAnimal>({} as UploadAnimal)
        const uploadImg = ref<UniFilePickerTempFile[]>([])
        const clearUploadData = () => {
            uploadData.value = {} as UploadAnimal;
        }
        return {uploadData, uploadImg, clearUploadData}
    },
    {
        persist: {
            storage: {
                setItem(key, value) {
                    uni.setStorageSync(key, value)
                },
                getItem(key) {
                    return uni.getStorageSync(key)
                },
            },
        },
    }
)